package com.cssy.yd.logic.web;

import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.annotation.Resource;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;

import org.apache.commons.lang.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRichTextString;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.CellRangeAddress;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.Mapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONArray;
import com.cssy.authority.entity.ScDepartmentDO;
import com.cssy.authority.service.IScDepartmentService;
import com.cssy.base.web.BaseController;
import com.cssy.base.web.BodyMsg;
import com.cssy.yd.basic.entity.BasicAreaDO;
import com.cssy.yd.basic.entity.BasicCompanyDO;
import com.cssy.yd.basic.entity.BasicCompanytypeDO;
import com.cssy.yd.basic.entity.BasicCurrencyDO;
import com.cssy.yd.basic.entity.BasicMeasurementUnitDO;
import com.cssy.yd.basic.entity.BasicModePaymentDO;
import com.cssy.yd.basic.service.IBasicCompanyService;
import com.cssy.yd.basic.service.IBasicCompanyTypeService;
import com.cssy.yd.basic.service.IBasicCurrencyService;
import com.cssy.yd.basic.service.IBasicMeasurementUnitService;
import com.cssy.yd.basic.service.IBasicModePaymentService;
import com.cssy.yd.logic.entity.LogicPoDO;
import com.cssy.yd.logic.entity.LogicPoItemDO;
import com.cssy.yd.logic.entity.LogicPoQuoteDO;
import com.cssy.yd.logic.entity.LogicSoDO;
import com.cssy.yd.logic.entity.LogicSoItemDO;
import com.cssy.yd.logic.service.ILogicPoItemService;
import com.cssy.yd.logic.service.ILogicPoService;
import com.cssy.yd.logic.util.ToRmbUtil;
import com.plat.exception.SyBaseException;
import com.plat.helper.JqGridHandler;
import com.plat.helper.SearchCondition;
import com.plat.helper.SearchConditions;
import com.plat.helper.SearchResult;
import com.plat.util.DateUtil;
import com.plat.util.DateUtils;
import com.plat.util.ExcelUtil;
import com.plat.util.GlobalResLoader;
import com.plat.util.OperationFlag;
import com.plat.util.SessionUtil;
import com.plat.util.json.AjaxUtil;
import com.plat.util.json.OutJsonGrid;
import com.yuendong.sy.exception.SyCodeException;

@Controller
@RequestMapping("/yd/logic/po")
public class PoController extends BaseController<LogicPoDO> {
	private static final String MANAGER = "/yd/logic/po/PoManager";// 列表页面
	private static final String EIDT = "/yd/logic/po/PoOperation";// 添加、修改、显示页面
	private static final String EIDTTIME = "/yd/logic/po/OperationTime";// 修改抵港显示页面
	private static final String MAIN = "/yd/logic/po/PoMain";//首页流程图

	@Resource(name = "logicPoService")
	private ILogicPoService logicPoService;
	
	@Resource(name = "logicPoItemService")
	private ILogicPoItemService logicPoItemService;
	
	
	@Resource(name = "basicCurrencyService")
	private IBasicCurrencyService basicCurrencyService;
	
	@Resource(name = "basicCompanyService")
	private IBasicCompanyService basicCompanyService;
	
	@Resource(name="basicModePaymentService")
	private IBasicModePaymentService basicModePaymentService;

	@Resource(name="scDepartmentService")
	private IScDepartmentService scDepartmentService;
	
	public String manager(HttpServletRequest request, Model model)
			throws Exception {
		return MANAGER;
	}

	
	@Override
	public void list(HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		 JqGridHandler hander=new JqGridHandler(request);
		 SearchConditions scs = new SearchConditions();
		 hander.getWheres(scs);
		 scs.setOrderBy("dctime desc");
		 SearchResult result= logicPoService.findListByExample(scs);
		 OutJsonGrid out=new OutJsonGrid(result);
		 out.printJSon(response);
	}
	
	

	@Override
	public String operationForm(HttpServletRequest request,
			@PathVariable String id, @PathVariable String flag, Model model)
			throws Exception {
		 
		if (OperationFlag.ADD.equals(flag)) {// 我新增加时操作
			model.addAttribute("flag", "ADD");
		} else {
			LogicPoDO lpd =logicPoService.findListById(id);
			/*SearchConditions scs = new SearchConditions();
			scs.setRemovedProperty(null);//判断是否有删除标识
			if(lpd.getId()!=null){
				 scs.addCondition("po_id", lpd.getId(), SearchCondition.OP_EQUAL);
			 }
			scs.setOrderBy("code asc");
			List<LogicPoItemDO> itemlistDos=logicPoItemService.findListByExample(scs).getResults();*/
			model.addAttribute("po", lpd);
			model.addAttribute("flag", "EDIT");
			//model.addAttribute("itemlistDos", itemlistDos);
		}
		//查询汇率
		 SearchConditions scs1 = new SearchConditions();
		 SearchResult result= basicCurrencyService.findListByExample(scs1);
		 List<BasicCurrencyDO> cd=result.getResults();
		 model.addAttribute("currency", cd);
		
		 SearchConditions scs2 = new SearchConditions();
		 scs2.addCondition("parentname","供应商",SearchCondition.OP_EQUAL);
		 scs2.setOrderBy("code asc");
		 SearchResult srsl= basicCompanyService.findListByExample(scs2);
		 List<BasicCompanyDO> bc=srsl.getResults();
		 model.addAttribute("company", bc);
		 
		 SearchConditions scs3 = new SearchConditions();
		 List<BasicModePaymentDO> paymentDOs = basicModePaymentService.findListByExample(scs3).getResults();
		 model.addAttribute("paymentDOs", paymentDOs);
		 
		 SearchConditions scs4 = new SearchConditions();
		List<ScDepartmentDO> departmentDOs=  scDepartmentService.findListByExample(scs4).getResults();
		model.addAttribute("departmentDOs", departmentDOs);
		return EIDT;
	}
	

	@RequestMapping("/griditems")
	public void griditems(HttpServletRequest request,HttpServletResponse response) throws Exception{
		String id = request.getParameter("id");
		if(StringUtils.isNotBlank(id)){
			LogicPoDO lpd =logicPoService.findListById(id);
			SearchConditions scs = new SearchConditions();
			 scs.setRemovedProperty(null);//判断是否有删除标识
			 if(lpd.getId()!=null){
				 scs.addCondition("po_id", lpd.getId(), SearchCondition.OP_EQUAL);
			 }
			scs.setOrderBy("code asc");
			List<LogicPoItemDO> itemlistDos=logicPoItemService.findListByExample(scs).getResults();
			OutJsonGrid out = new OutJsonGrid(itemlistDos);
			out.printJSon(response);
		}
	}
	
	@Override
	public Map<String, Object> save(HttpServletRequest request,
			LogicPoDO curAP, BindingResult result, Model model) throws SyBaseException, SyCodeException {
		BodyMsg bodyMap = BodyMsg.getInstance();
		String itemdata =request.getParameter("itemdata");
		if(itemdata==null&&"".equals(itemdata)){
			bodyMap.isFail();
			bodyMap.configWebInfor("采购订单内容不能为空！");
			return bodyMap.modelMap;
		}try {
					logicPoService.poSave(request, curAP);
					bodyMap.isSuccess();
					bodyMap.configWebInfor(GlobalResLoader.getOpsuccess());
					bodyMap.configWebId(curAP.getId());
				
		} catch (Exception e) {
			e.printStackTrace();
			bodyMap.isFail();
			bodyMap.configWebInfor(GlobalResLoader.getOpfailed()
					+ e.getMessage());
		}
		return bodyMap.modelMap;
	}
	
	
	@Override
	public Map<String, Object> delete(HttpServletRequest request,
			HttpServletResponse response, Model model) throws Exception {
		BodyMsg bodyMap = BodyMsg.getInstance();
		try {
			String ids = request.getParameter("ids");
			String[] fields=ids.split(",");
			for(String field : fields){
				LogicPoDO ld=logicPoService.findListById(field);
				if(ld!=null){
					ld.setRemoved(Short.parseShort("1"));
					logicPoService.update(ld, SessionUtil.getUser(request));
				}
			}
			bodyMap.isSuccess(GlobalResLoader.getOpsuccess());
		} catch (Exception e) {
			e.printStackTrace();
			bodyMap.isFail(GlobalResLoader.getOpfailed() + e.getMessage());
		}
		return bodyMap.modelMap;
	}

	@RequestMapping(value = "/operatetime/{flag}/{id}")
	public String operationTime(HttpServletRequest request,@PathVariable String id,@PathVariable String flag, Model model) throws Exception{
		if (OperationFlag.ADD.equals(flag)) {// 我新增加时操作
			model.addAttribute("flag", "ADD");
		} else {
			LogicPoDO lpd =logicPoService.findListById(id);
			model.addAttribute("po", lpd);
			model.addAttribute("flag", "EDIT");
		}
		return EIDTTIME;
	}
	
	/**
	 * 模块首页
	 * @param request
	 * @param response
	 * @param model
	 * @return
	 * @author huang.xuming [2013-9-3]
	 */
	@RequestMapping("/main")
	public String mainpage(HttpServletRequest request,
			HttpServletResponse response, Model model){
		return MAIN;
	}
	
//	@RequestMapping(value = "/savetime", method = RequestMethod.POST)
//	@ResponseBody
//	public Map<String, Object> savetime(HttpServletRequest request,
//			LogicPoDO curAP, BindingResult result, Model model) throws SyBaseException, SyCodeException {
//		BodyMsg bodyMap = BodyMsg.getInstance();
//		try {
//			String dgrq=request.getParameter("dgrq");
//			Date date=new Date();
//			String dt=DateUtils.dateToString(date, "yyyy-MM-dd");
//			if(dgrq.equals(dt)){
//				bodyMap.isFail();
//				bodyMap.configWebInfor("到港时间必须大于当天，请重新修改");
//				return bodyMap.modelMap;
//			}
//			LogicPoDO lp=logicPoService.findListById(curAP.getId());
//			lp.setDgrq(DateUtils.stringToDate(dgrq));
//			int ret=logicPoService.update(lp, SessionUtil.getUser(request));
//			if(ret==1){
//				bodyMap.isSuccess();
//				bodyMap.configWebInfor(GlobalResLoader.getOpsuccess());
//				bodyMap.configWebId(curAP.getId());
//			}else{
//				bodyMap.isFail();
//				bodyMap.configWebInfor("您修改的数据已发生改变，请重新点开查看");
//			}
//		} catch (Exception e) {
//			e.printStackTrace();
//			bodyMap.isFail();
//			bodyMap.configWebInfor(GlobalResLoader.getOpfailed()
//					+ e.getMessage());
//		}
//		return bodyMap.modelMap;
//	}
	/**
	 * 导出单据详细信息
	 * @param request
	 * @param response
	 * @param model
	 * @throws IOException 
	**/
//	@RequestMapping(value = "/exportExcel")
//	public void exportExcel(HttpServletRequest request, HttpServletResponse response, Model model) throws IOException{
//		try{
//			String id = request.getParameter("id");
//			LogicPoDO lpd=new LogicPoDO();
//			List<LogicPoItemDO> lp=new ArrayList<LogicPoItemDO>();
//			if(!"".equals(id)&&id!=null){
//				lpd =logicPoService.findListById(id);
//			}
//			if(lpd.getId()!=null){
//				SearchConditions scs = new SearchConditions();
//				scs.addCondition("po_id", lpd.getId(),SearchCondition.OP_EQUAL);
//				scs.setLimitPage(false);
//				scs.setRemovedProperty(null);
//				lp =logicPoItemService.findListByExample(scs).getResults();
//			}
//			if(lp.size()>0){
//				HSSFWorkbook workbook = new HSSFWorkbook();// 创建一个Excel文件
//				HSSFSheet sheet = workbook.createSheet();// 创建一个Excel的Sheet
//				HSSFRow row0 = sheet.createRow(0);
//				// 设置行高
//				HSSFCell cell0 = row0.createCell(6);
//				cell0.setCellValue(new HSSFRichTextString("深圳市罗湖区人民南路深圳嘉里中心2601室"));
//				CellRangeAddress range = new CellRangeAddress(0, 0, 6, 12);
//				sheet.addMergedRegion(range);
//				
//				HSSFRow row1 = sheet.createRow(1);
//				HSSFCell cell1 = row1.createCell(6);
//				cell1.setCellValue(new HSSFRichTextString("TEL:（0755）8217 8777 FAX:（0755）8225 1045"));
//				CellRangeAddress range1 = new CellRangeAddress(1, 1, 6, 12);
//				sheet.addMergedRegion(range1);
//				
//				HSSFRow row2 = sheet.createRow(2);
//				row2.setHeight((short) 500);
//				HSSFCell cell2 = row2.createCell(5);
//				cell2.setCellValue(new HSSFRichTextString(lpd.getAegnt()));
//				CellRangeAddress range2 = new CellRangeAddress(2, 2, 5, 12);
//				sheet.addMergedRegion(range2);
//				
//				HSSFRow row3 = sheet.createRow(3);
//				HSSFCell cell3 = row3.createCell(5);
//				cell3.setCellValue(new HSSFRichTextString("采购订单"));
//				CellRangeAddress range3 = new CellRangeAddress(3, 3, 5, 12);
//				sheet.addMergedRegion(range3);
//				
//				HSSFRow row4 = sheet.createRow(4);
//				row4.setHeight((short) 500);
//				HSSFCell cell4 = row4.createCell(8);
//				cell4.setCellValue(new HSSFRichTextString("制单日期："));
//				
//				HSSFCell cell5 = row4.createCell(9);
//				cell5.setCellValue(new HSSFRichTextString(DateUtils.dateToString(lpd.getDctime(), "yyyy-MM-dd")));
//				CellRangeAddress range4 = new CellRangeAddress(4, 4, 9, 12);
//				sheet.addMergedRegion(range4);
//				
//				HSSFRow row5 = sheet.createRow(5);
//				HSSFCell cell6 = row5.createCell(6);
//				cell6.setCellValue(new HSSFRichTextString("制 单 人 员 填 写"));
//				CellRangeAddress range5 = new CellRangeAddress(5, 5, 6, 12);
//				sheet.addMergedRegion(range5);
//				
//				HSSFRow row6 = sheet.createRow(6);
//				row6.setHeight((short) 700);
//				HSSFCell cell = row6.createCell(0);
//				cell.setCellValue(new HSSFRichTextString("采购编号"));
//				cell = row6.createCell(1);
//				cell.setCellValue(new HSSFRichTextString("供应商名称"));
//				cell = row6.createCell(2);
//				cell.setCellValue(new HSSFRichTextString("采购方式"));
//				cell = row6.createCell(3);
//				cell.setCellValue(new HSSFRichTextString("部门"));
//				cell = row6.createCell(4);
//				cell.setCellValue(new HSSFRichTextString("摘要"));
//				cell = row6.createCell(5);
//				cell.setCellValue(new HSSFRichTextString("订购日期"));
//				cell = row6.createCell(6);
//				cell.setCellValue(new HSSFRichTextString("收货日期"));
//				cell = row6.createCell(7);
//				cell.setCellValue(new HSSFRichTextString("结算日期"));
//				cell = row6.createCell(8);
//				cell.setCellValue(new HSSFRichTextString("入库日期"));
//				cell = row6.createCell(9);
//				cell.setCellValue(new HSSFRichTextString("物料名称"));
//				cell = row6.createCell(10);
//				cell.setCellValue(new HSSFRichTextString("单位"));
//				cell = row6.createCell(11);
//				cell.setCellValue(new HSSFRichTextString("采购数量"));
//				cell = row6.createCell(12);
//				cell.setCellValue(new HSSFRichTextString("采购数量"));
//				
//				HSSFRow row7 = sheet.createRow(7);
//				row7.setHeight((short) 700);
//				HSSFCell cell7 = row7.createCell(0);
//				cell7.setCellValue(lpd.getPocode());
//				cell7 = row7.createCell(1);
//				cell7.setCellValue(lpd.getSpname());
//				cell7 = row7.createCell(2);
//				cell7.setCellValue(lpd.getPopattern());
//				cell7 = row7.createCell(3);
//				cell7.setCellValue(lpd.getDepname());
//				cell7 = row7.createCell(4);
//				cell7.setCellValue(lpd.getTabloid());
//				cell7 = row7.createCell(5);
//				cell7.setCellValue(new HSSFRichTextString(DateUtils.dateToString(lpd.getDgrq(), "yyyy-MM-dd")));
//				cell7 = row7.createCell(6);
//				cell7.setCellValue(new HSSFRichTextString(DateUtils.dateToString(lpd.getShrq(), "yyyy-MM-dd")));
//				cell7 = row7.createCell(7);
//				cell7.setCellValue(new HSSFRichTextString(DateUtils.dateToString(lpd.getFkdate(), "yyyy-MM-dd")));
//				cell7 = row7.createCell(8);
//				cell7.setCellValue(new HSSFRichTextString(""));
//				cell7 = row7.createCell(9);
//				cell7.setCellValue(lp.get(0).getName());
//				cell7 = row7.createCell(10);
//				cell7.setCellValue(lp.get(0).getJunit());
//				cell7 = row7.createCell(11);
//				cell7.setCellValue(lp.get(0).getJquantity());
//				cell7 = row7.createCell(12);
//				cell7.setCellValue(lp.get(0).getJquantity());
//				
//				HSSFRow row8 = sheet.createRow(8);
//				HSSFCell cell8 = row8.createCell(0);
//				cell8.setCellValue(new HSSFRichTextString("备注："));
//				HSSFCell cell9 = row8.createCell(1);
//				cell9.setCellValue(new HSSFRichTextString(lpd.getRemark()));
//				CellRangeAddress range8 = new CellRangeAddress(8, 8, 1, 12);
//				sheet.addMergedRegion(range8);
//				
//				HSSFRow row9 = sheet.createRow(9);
//				HSSFCell cell10 = row9.createCell(0);
//				cell10.setCellValue(new HSSFRichTextString("制单/日期："));
//				HSSFCell cell11 = row9.createCell(1);
//				cell11.setCellValue(new HSSFRichTextString(DateUtils.dateToString(lpd.getDctime(), "yyyy-MM-dd")));
//				CellRangeAddress range9 = new CellRangeAddress(9, 9, 1, 12);
//				sheet.addMergedRegion(range9);
//				
//				HSSFRow row11 = sheet.createRow(11);
//				HSSFCell cell12 = row11.createCell(6);
//				cell12.setCellValue(new HSSFRichTextString("仓 管 人 员 填 写"));
//				CellRangeAddress range10 = new CellRangeAddress(11, 11, 6, 12);
//				sheet.addMergedRegion(range10);
//				
//				HSSFRow row12 = sheet.createRow(12);
//				row12.setHeight((short) 500);
//				HSSFCell cell13 = row12.createCell(0);
//				cell13.setCellValue(new HSSFRichTextString("入库日期"));
//				HSSFCell cell14 = row12.createCell(2);
//				cell14.setCellValue(new HSSFRichTextString("入库数量(吨)"));
//				CellRangeAddress range11 = new CellRangeAddress(12, 12, 1, 4);
//				sheet.addMergedRegion(range11);
//				HSSFCell cell15 = row12.createCell(5);
//				cell15.setCellValue(new HSSFRichTextString("差额(吨)"));
//				HSSFCell cell16 = row12.createCell(8);
//				cell16.setCellValue(new HSSFRichTextString("备注"));
//				CellRangeAddress range12 = new CellRangeAddress(12, 12, 8, 12);
//				sheet.addMergedRegion(range12);
//				
//				HSSFRow row13 = sheet.createRow(14);
//				row13.setHeight((short) 500);
//				HSSFCell cell17 = row13.createCell(0);
//				cell17.setCellValue(new HSSFRichTextString("仓管/日期："));
//				HSSFCell cell18 = row13.createCell(5);
//				cell18.setCellValue(new HSSFRichTextString("主管/日期："));
//				HSSFCell cell19 = row13.createCell(9);
//				cell19.setCellValue(new HSSFRichTextString("财务/日期：  "));
//				
//				String fileNameDisplay = "采购订单"
//						+ new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
//				try {
//					fileNameDisplay = new String(fileNameDisplay.getBytes("GBK"),
//							"iso-8859-1");
//				} catch (UnsupportedEncodingException e1) {
//					e1.printStackTrace();
//				}
//				fileNameDisplay = fileNameDisplay.replace(" ", "%20");
//				response.addHeader("Content-Disposition", "attachment;filename="
//						+ fileNameDisplay + ".xls");
//			    response.setContentType("application/vnd.ms-excel"); 
//			    OutputStream ouputStream = response.getOutputStream();  
//			    workbook.write(ouputStream);  
//			    ouputStream.flush();  
//			    ouputStream.close();  
//			}
//		}catch(Exception e){
//			e.printStackTrace();
//		}
//	}
	
	@RequestMapping(value = "/exportExcel")
	public void printer(HttpServletRequest request, HttpServletResponse response) throws Exception{

		try {
			String id = request.getParameter("id");
			LogicPoDO lpd=new LogicPoDO();
			List<LogicPoItemDO> lp=new ArrayList<LogicPoItemDO>();
			if(!"".equals(id)&&id!=null){
				lpd =logicPoService.findListById(id);
			}
			if(lpd.getId()!=null){
				SearchConditions scs = new SearchConditions();
				scs.addCondition("po_id", lpd.getId(),SearchCondition.OP_EQUAL);
				scs.setLimitPage(false);
				scs.setRemovedProperty(null);
				lp =logicPoItemService.findListByExample(scs).getResults();
			}
//			List<Map<String,Object>> dateMapRows = this.getMapDateRows(purOrderItemDAO.getByPOId(id));
//			Map<String,Object> map = this.getMapDate(purOrder);
			if(lp.size()>0){
				String upperMoney = "";
				double lowerMoney = 0;
				for (LogicPoItemDO logicPoItemDO : lp) {
					lowerMoney +=logicPoItemDO.getSumPMoney();
				}
				if(lowerMoney>0){
					upperMoney=ToRmbUtil.toChineseCharacter(lowerMoney);
				}
				request.setAttribute("lpd", lpd);
				request.setAttribute("lp", lp);
				request.setAttribute("row", lp.size());
				request.setAttribute("upperMoney", upperMoney);
				request.setAttribute("lowerMoney", lowerMoney);
				request.setAttribute("time", new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
				
				response.setContentType("application/vnd.ms-excel");
				response.setHeader("Content-disposition", "attachment;filename=" + lpd.getPocode() + ".xls");
			
				RequestDispatcher dispatcher = request.getRequestDispatcher("/views/printer/PoPrint.jsp");
			
				dispatcher.forward(request, response);
			}
		} catch (ServletException e) {
			e.printStackTrace();
		}
	}
	
//	@RequestMapping(value = "/updateState")
//	public void updateState(HttpServletRequest request,HttpServletResponse response)throws Exception{
//		String id = request.getParameter("rows");
//		Map<String,String> map =new HashMap<String, String>();
//		try{
//			LogicPoDO logicPoDO = logicPoService.findListById(id);
//			logicPoDO.setBillstatus("0");
//			logicPoService.update(logicPoDO,  SessionUtil.getUser(request));
//		map.put("msg", "SUCCESS");
//		}catch(Exception e){
//			e.printStackTrace();
//			map.put("msg", "ERROR");
//		}
//		AjaxUtil.printJSonArr(response, JSONObject.fromObject(map).toString());
//	}
	
	@RequestMapping("/getGysInfo")
	public void getGysInfo(HttpServletResponse response,@RequestParam("gysCode") String gysCode){
		SearchConditions scs = new SearchConditions();
		 scs.addCondition("parentname","供应商",SearchCondition.OP_EQUAL);
		 scs.addCondition("code",gysCode,SearchCondition.OP_EQUAL);
		 SearchResult sr= basicCompanyService.findListByExample(scs);
		 List<BasicCompanyDO> bc =sr.getResults();
		
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("gys", bc.get(0));
		AjaxUtil.printJSonArr(response, JSONArray.toJSONString(map));
	}
	
}
